load("@rules_proto//proto:defs.bzl", "proto_library")

# This is an API workspace, having public visibility by default makes perfect sense.
package(default_visibility = ["//visibility:public"])

##############################################################################
# Common
##############################################################################
load("@com_google_googleapis_imports//:imports.bzl", "proto_library_with_info")

proto_library(
    name = "iam_policy_proto",
    srcs = ["iam_policy.proto"],
    deps = [
        ":options_proto",
        ":policy_proto",
        "//google/api:annotations_proto",
        "//google/api:client_proto",
        "//google/api:field_behavior_proto",
        "//google/api:resource_proto",
    ],
)

proto_library(
    name = "policy_proto",
    srcs = ["policy.proto"],
    deps = [
        "//google/api:annotations_proto",
        "//google/type:expr_proto",
    ],
)

proto_library(
    name = "options_proto",
    srcs = ["options.proto"],
    deps = [
        "//google/api:annotations_proto",
    ],
)

proto_library_with_info(
    name = "iam_proto_with_info",
    deps = [
        ":iam_policy_proto",
        ":options_proto",
        ":policy_proto",
    ],
)

##############################################################################
# Java
##############################################################################
load("@com_google_googleapis_imports//:imports.bzl", "java_grpc_library", "java_proto_library")

java_proto_library(
    name = "iam_java_proto",
    deps = [
        ":iam_policy_proto",
        ":policy_proto",
        ":options_proto",
    ],
)

java_grpc_library(
    name = "iam_java_grpc",
    srcs = [":iam_policy_proto"],
    deps = [":iam_java_proto"],
)

##############################################################################
# Go
##############################################################################
load(
    "@com_google_googleapis_imports//:imports.bzl",
    "go_gapic_assembly_pkg",
    "go_proto_library",
)

go_proto_library(
    name = "iam_go_proto",
    compilers = ["@io_bazel_rules_go//proto:go_grpc"],
    importpath = "google.golang.org/genproto/googleapis/iam/v1",
    protos = [
        ":iam_policy_proto",
        ":options_proto",
        ":policy_proto",
    ],
    deps = [
        "//google/api:annotations_go_proto",
        "//google/type:expr_go_proto",
    ],
)

go_gapic_assembly_pkg(
    name = "gapi-cloud-iam-v1-go",
    deps = [
        ":iam_go_proto",
    ],
)

##############################################################################
# C++
##############################################################################
load(
    "@com_google_googleapis_imports//:imports.bzl",
    "cc_proto_library",
    "cc_grpc_library")

cc_proto_library(
    name = "iam_policy_cc_proto",
    deps = [":iam_policy_proto"],
)

cc_proto_library(
    name = "options_cc_proto",
    deps = [":options_proto"],
)

cc_proto_library(
    name = "policy_cc_proto",
    deps = [":policy_proto"],
)

cc_grpc_library(
    name = "iam_cc_grpc",
    srcs = [":iam_policy_proto"],
    grpc_only = True,
    deps = [":iam_policy_cc_proto"],
)

##############################################################################
# Python
# ##############################################################################
load(
    "@com_google_googleapis_imports//:imports.bzl",
    "py_proto_library",
)

py_proto_library(
    name = "iam_policy_py_proto",
    deps = [":iam_policy_proto"]
)

py_proto_library(
    name = "policy_py_proto",
    deps = [":policy_proto"]
)

py_proto_library(
    name = "options_py_proto",
    deps = [":options_proto"]
)
